Codeforces Round #524 (Div. 2)
A. Petya and Origami
题目大意:
需要邀请n个人来参加派对.需要制作邀请卡.一张邀请卡需要2红, 5绿, 8蓝. 每个笔记本有k个某种颜色.求最少需要多少个笔记本.
题解
答案显示是$ \lceil 2n/k \rceil + \lceil 5n/k \rceil + \lceil 8n/k \rceil $
1 |
|
B. Margarite and the best present
题目大意:
有一个序列. $a_i = i*(-1)^i$. 给定l, r. 求$\sum_{i = l} ^ ra_i$.
题解
将这个序列看成两个等差序列.利用等差序列求和公式即可.
1 |
|
C. Masha and two friends
题目大意:
AC
一开始有一个棋盘有黑白两种颜色。一开始将区域一(x1 y1) (x2 x2)这个区域(左下角和右下角的点构成一个矩形区域)全部涂成白色。然后将区域二(x3 y3) (x4 y4)这个区域全部涂成黑色.求最后棋盘上黑白的格子各有多少.
题解
计算区域一(x1 y1) (x2 y2)区域中一开始有白色格子w1 黑色格子b1
计算区域二(x3 y3) (x4 y4)区域中一开始有白色格子w3 黑色格子b3
计算上面两个区域相交的区域三(x5 y5) (x6 x6)区域中一开始有白色格子w2 黑色格子b2
一开始棋盘上有orw个白格子.orb个黑格子.
- 区域一涂成白色. orw += b1, orb -= b1
- 区域二和区域一二相交的地方区域三涂成黑色
2.1 获得区域二的白色 orb += w3, orw -= w3
2.2 获得相交部分的黑色 orb += b2, orw -= b2
在orb基础上增加的黑格子的数量是w3 + b2 - b1
对应的.在orw基础上减少的白格子的数量是-(w3 + b2 - b1)
1 |
|